package com.xyazm.order.remote;

import com.xyazm.address.api.IAddressApi;
import com.xyazm.address.domain.dto.AddressDTO;
import com.xyazm.address.domain.param.QueryAddressParam;
import com.xyazm.common.core.JsonResult;
import com.xyazm.common.utils.CheckResultUtil;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * 地址服务远程调用接口
 * @author xuyou
 * @date 2022年11月01日 20:59
 */
@Component
public class AddressRemote {

    /**
     * 地址服务
     */
    @DubboReference(version = "1.0.0")
    private IAddressApi addressApi;

    /**
     * 查询行政地址
     * @param queryAddressParam
     * @return
     */
    public AddressDTO queryAddress(QueryAddressParam queryAddressParam) {
        JsonResult<AddressDTO> result = addressApi.getAddress(queryAddressParam);
        // 检查api调用结果
        CheckResultUtil.checkResult(result,"查询行政地址");
        return result.getData();
    }

}
